<?php



namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;

class SyncedAccountEvent implements  ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public  $userId;

    public $nickname;

    public $avatar;

    /**
     * SyncedAccountEvent constructor.
     * @param int $userId
     * @param string $nickname
     * @param string $avatar
     */
    public function __construct(int $userId, string $nickname = '', string $avatar = '')
    {
        $this->userId = $userId;
        $this->nickname = $nickname;
        $this->avatar = $avatar;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     *
     * @codeCoverageIgnore
     */
    public function broadcastOn()
    {
        return new Channel('synced_account');
    }

    /**
     * @return string
     */
    public function broadcastAs()
    {
        return 'SyncedAccountEvent';
    }


}
